<template>
  <div id="app">
    <!-- <router-view/> -->
    <div class="wrap">
      <div
        class="bg"
        v-show="noteVisible"
        :style="noteStyle"/>
      <timeSelector
        v-for="(item,index) in testData"
        :key="index"
        :data="item"
        ref="timeSelector"
        @change="handleChange"
        @done="handleDone($event,index)"/>
    </div>
  </div>
</template>

<script>
import data from './data.js'
import timeSelector from '@/components/TimeSelector/main'
export default {
  name: 'App',
  data () {
    return {
      testData: [data, [], []],
      noteVisible: false,
      noteStyle: {
        left: 0,
        right: '100%'
      }
    }
  },
  components: {
    timeSelector
  },
  methods: {
    handleDone (val, index) {
      console.log(val)
      this.noteVisible = false
      // this.$refs.timeSelector[index].hideItem()
    },
    handleChange (val) {
      this.noteVisible = true
      this.noteStyle = {
        left: val.left * 100 + '%',
        right: val.right * 100 + '%'
      }
    }
  }
}
</script>

<style>
#app {
  font-family: 'Avenir', Helvetica, Arial, sans-serif;
  -webkit-font-smoothing: antialiased;
  -moz-osx-font-smoothing: grayscale;
  text-align: center;
  color: #2c3e50;
  margin-top: 60px;
}
.wrap{
  position: relative;
}
.bg{
  position: absolute;height: 100%; background: rgba(228, 196, 13, 0.5);
}
</style>
